<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- saved from url=(0039)http://flysnowxf.iteye.com/blog/1188496 -->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN" dir="ltr"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    
    <title>java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站</title>
    <meta name="description" content="这里申请了1000个线程，并且执行1000次任务。当所有任务完成后，main退出。 public class Test {       public static void main(String[] args) {            int count = 1000;            ExecutorService executorService = Executors.newFixed ...">
    <meta name="keywords" content="java, 并发, 测试 java并发测试用例模板">
    <link rel="shortcut icon" href="http://flysnowxf.iteye.com/images/favicon.ico" type="image/x-icon">
    <link rel="search" type="application/opensearchdescription+xml" href="http://flysnowxf.iteye.com/open_search.xml" title="ITeye">
    <link href="http://flysnowxf.iteye.com/rss" rel="alternate" title="flysnowxf技术博客" type="application/rss+xml">
    <link href="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/blog.css" media="screen" rel="stylesheet" type="text/css">
<link href="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/blue.css" media="screen" rel="stylesheet" type="text/css">
    <script type="text/javascript" async="" src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/ga.js"></script><script type="text/javascript" async="" src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/ga.js"></script><script src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/application.js" type="text/javascript"></script>    
    <script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-535605-1']);
  _gaq.push(['_setDomainName', 'iteye.com']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>


      <link href="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/SyntaxHighlighter.css" media="screen" rel="stylesheet" type="text/css">
  <script src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/shCoreCommon.js" type="text/javascript"></script>
<script src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/hotkey.js" type="text/javascript"></script>
  <script src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/code_favorites.js" type="text/javascript"></script>
<script src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/weiboshare.js" type="text/javascript"></script>
  <link href="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/ui.css" media="screen" rel="stylesheet" type="text/css">
  <script src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/compress.js" type="text/javascript"></script>
    
  <style type="text/css">.dp-j .annotation { color: #646464; }.dp-j .number { color: #C00000; }</style><style type="text/css">.dp-j .annotation { color: #646464; }.dp-j .number { color: #C00000; }</style></head>
  <body>
    <div id="header">
	      <div id="blog_site_nav">
  <a href="http://www.iteye.com/" class="homepage">首页</a>
  <a href="http://www.iteye.com/news">资讯</a>
  <a href="http://www.iteye.com/magazines">精华</a>
  <a href="http://www.iteye.com/forums">论坛</a>
  <a href="http://www.iteye.com/ask">问答</a>
  <a href="http://www.iteye.com/blogs">博客</a>
  <a href="http://www.iteye.com/blogs/subjects">专栏</a>
  <a href="http://www.iteye.com/groups">群组</a>
  <a href="http://flysnowxf.iteye.com/blog/1188496#" onclick="return false;" id="msna"><u>更多</u> <small>▼</small></a>
  <div class="quick_menu" style="display:none;">
    <a target="_blank" href="http://job.iteye.com/iteye">知识库</a>
    <a href="http://www.iteye.com/search">搜索</a>
  </div>
</div>

	      <div id="user_nav">
  
        <a href="http://haiyang4988.iteye.com/" title="查看我的博客首页" class="welcome">欢迎haiyang4988</a>
    <a id="notifications_count" href="http://my.iteye.com/notifications">0</a>
    
      <a href="http://my.iteye.com/messages" title="你有新的站内短信"><img alt="Newpm" src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/newpm.gif">收件箱(1)</a>
    
    <a href="http://my.iteye.com/" title="我的应用首页">我的应用</a>
    <div class="quick_menu" style="display:none;">
      <a href="http://my.iteye.com/feed" title="我关注的好友动态消息">我的关注</a>
      <a href="http://my.iteye.com/mygroup" title="我加入的群组最新话题">我的群组</a>
      <a href="http://my.iteye.com/myresume" title="我的个人简历">我的简历</a>
      <a href="http://my.iteye.com/admin/album" title="我的个人简历">我的相册</a>
      <a href="http://my.iteye.com/admin/link" title="我收藏的网络资源链接">我的收藏</a>
      <a href="http://my.iteye.com/admin/code" title="我收藏的代码">我的代码</a>
      <a href="http://my.iteye.com/admin/weibo" title="用微博发表简短的话题">我的微博</a>
    </div>
    <a href="http://haiyang4988.iteye.com/admin" title="管理我的博客">我的博客</a>
    <a href="http://my.iteye.com/profile" title="修改我的个人设置">设置</a>
    <a href="http://flysnowxf.iteye.com/logout" class="nobg" onclick="var f = document.createElement(&#39;form&#39;); f.style.display = &#39;none&#39;; this.parentNode.appendChild(f); f.method = &#39;POST&#39;; f.action = this.href;var m = document.createElement(&#39;input&#39;); m.setAttribute(&#39;type&#39;, &#39;hidden&#39;); m.setAttribute(&#39;name&#39;, &#39;_method&#39;); m.setAttribute(&#39;value&#39;, &#39;put&#39;); f.appendChild(m);var s = document.createElement(&#39;input&#39;); s.setAttribute(&#39;type&#39;, &#39;hidden&#39;); s.setAttribute(&#39;name&#39;, &#39;authenticity_token&#39;); s.setAttribute(&#39;value&#39;, &#39;jBwEOXnoendouP0ySYchqzCPkfQkm4V54086TLW4dVY=&#39;); f.appendChild(s);f.submit();return false;">退出</a>
  </div>

	    
    </div>

    <div id="page">
        <div id="branding" class="clearfix" style="overflow: hidden;background: none;padding:0 0 2px;">
        	<ins data-revive-zoneid="184" data-revive-id="8c38e720de1c90a6f6ff52f3f89c4d57"></ins>
        </div>
      <div id="branding" class="clearfix">
        <div id="blog_name">
          <h1><a href="http://flysnowxf.iteye.com/">flysnowxf技术博客</a></h1>
        </div>
        <div id="fd"></div>
        <div id="blog_navbar">
          <ul>
            <li class="blog_navbar_for"><a href="http://flysnowxf.iteye.com/"><strong>博客</strong></a></li>
            <li><a href="http://flysnowxf.iteye.com/weibo">微博</a></li>
            <li><a href="http://flysnowxf.iteye.com/album">相册</a></li>
            <li><a href="http://flysnowxf.iteye.com/link">收藏</a></li>
            <li><a href="http://flysnowxf.iteye.com/blog/guest_book">留言</a></li>
            <li><a href="http://flysnowxf.iteye.com/blog/profile">关于我</a></li>
          </ul>
    
          <div class="search">
            <form action="http://flysnowxf.iteye.com/blog/search" method="get">
              <input class="search_text" id="query" name="query" style="margin-left: 10px;width: 110px;" type="text" value="">
              <input class="submit_search" type="submit" value="">
            </form>
          </div> 
          <div id="fd"></div>         
        </div>
      </div>
      
      <div id="content" class="clearfix">
        <div id="main">
          



          


<div class="h-entry" style="display:none">
  <a href="http://flysnowxf.iteye.com/" class="p-author" target="_blank">flysnowxf</a>
</div>


<div class="blog_main">
  <div class="blog_title">
    <h3>
      <a href="http://flysnowxf.iteye.com/blog/1188496">java并发测试用例模板</a>
      <em class="actions">      </em>
    </h3>
    <ul class="blog_categories"><strong>博客分类：</strong> <li><a href="http://flysnowxf.iteye.com/category/95072">Java</a></li> </ul>
        <div class="news_tag"><a href="http://www.iteye.com/blogs/tag/java">java</a><a href="http://www.iteye.com/blogs/tag/%E5%B9%B6%E5%8F%91">并发</a><a href="http://www.iteye.com/blogs/tag/%E6%B5%8B%E8%AF%95">测试</a>&nbsp;</div>
    	  
    	
    	
  		
      </div>

  <div id="blog_content" class="blog_content">
    这里申请了1000个线程，并且执行1000次任务。当所有任务完成后，main退出。
<br><div class="dp-highlighter" id=""><div class="bar"><div class="tools">Java代码 <embed wmode="transparent" src="/javascripts/syntaxhighlighter/clipboard_new.swf" width="14" height="15" flashvars="clipboard=public%20class%20Test%20%7B%0A%20%20%20%20%20public%20static%20void%20main(String%5B%5D%20args)%20%7B%0A%20%20%20%20%20%20%20%20%20%20int%20count%20%3D%201000%3B%0A%20%20%20%20%20%20%20%20%20%20ExecutorService%20executorService%20%3D%20Executors.newFixedThreadPool(count)%3B%0A%20%20%20%20%20%20%20%20%20%20for%20(int%20i%20%3D%200%3B%20i%20%3C%20count%3B%20i%2B%2B)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20executorService.execute(new%20Test().new%20Task())%3B%0A%0A%20%20%20%20%20%20%20%20%20%20executorService.shutdown()%3B%0A%20%20%20%20%20%20%20%20%20%20while%20(!executorService.isTerminated())%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20try%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Thread.sleep(10)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%20catch%20(InterruptedException%20e)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20e.printStackTrace()%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%7D%0A%0A%20%20%20%20%20public%20class%20Task%20implements%20Runnable%20%7B%0A%0A%20%20%20%20%20%20%20%20%20%20%40Override%0A%20%20%20%20%20%20%20%20%20%20public%20void%20run()%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20try%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2F%2F%20%E6%B5%8B%E8%AF%95%E5%86%85%E5%AE%B9%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%20catch%20(Exception%20e)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20e.printStackTrace()%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%7D%0A%7D" quality="high" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">&nbsp;<a href="javascript:void()" title="收藏这段代码" onclick="code_favorites_do_favorite(this);return false;"><img class="star" src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/icon_star.png" alt="收藏代码"><img class="spinner" src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/spinner.gif" style="display:none"></a></div></div><ol start="1" class="dp-j"><li><span><span class="keyword">public</span><span>&nbsp;</span><span class="keyword">class</span><span>&nbsp;Test&nbsp;{&nbsp;&nbsp;</span></span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">public</span><span>&nbsp;</span><span class="keyword">static</span><span>&nbsp;</span><span class="keyword">void</span><span>&nbsp;main(String[]&nbsp;args)&nbsp;{&nbsp;&nbsp;</span></span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">int</span><span>&nbsp;count&nbsp;=&nbsp;</span><span class="number">1000</span><span>;&nbsp;&nbsp;</span></span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ExecutorService&nbsp;executorService&nbsp;=&nbsp;Executors.newFixedThreadPool(count);&nbsp;&nbsp;</span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">for</span><span>&nbsp;(</span><span class="keyword">int</span><span>&nbsp;i&nbsp;=&nbsp;</span><span class="number">0</span><span>;&nbsp;i&nbsp;&lt;&nbsp;count;&nbsp;i++)&nbsp;&nbsp;</span></span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;executorService.execute(<span class="keyword">new</span><span>&nbsp;Test().</span><span class="keyword">new</span><span>&nbsp;Task());&nbsp;&nbsp;</span></span></li><li><span>&nbsp;&nbsp;</span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;executorService.shutdown();&nbsp;&nbsp;</span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">while</span><span>&nbsp;(!executorService.isTerminated())&nbsp;{&nbsp;&nbsp;</span></span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">try</span><span>&nbsp;{&nbsp;&nbsp;</span></span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Thread.sleep(<span class="number">10</span><span>);&nbsp;&nbsp;</span></span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<span class="keyword">catch</span><span>&nbsp;(InterruptedException&nbsp;e)&nbsp;{&nbsp;&nbsp;</span></span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e.printStackTrace();&nbsp;&nbsp;</span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li><span>&nbsp;&nbsp;</span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">public</span><span>&nbsp;</span><span class="keyword">class</span><span>&nbsp;Task&nbsp;</span><span class="keyword">implements</span><span>&nbsp;Runnable&nbsp;{&nbsp;&nbsp;</span></span></li><li><span>&nbsp;&nbsp;</span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="annotation">@Override</span><span>&nbsp;&nbsp;</span></span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">public</span><span>&nbsp;</span><span class="keyword">void</span><span>&nbsp;run()&nbsp;{&nbsp;&nbsp;</span></span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">try</span><span>&nbsp;{&nbsp;&nbsp;</span></span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">//&nbsp;测试内容</span><span>&nbsp;&nbsp;</span></span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<span class="keyword">catch</span><span>&nbsp;(Exception&nbsp;e)&nbsp;{&nbsp;&nbsp;</span></span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e.printStackTrace();&nbsp;&nbsp;</span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li><span>}&nbsp;&nbsp;</span></li></ol></div><pre class="java" name="code" codeable_id="" codeable_type="BlogComment" source_url="http://flysnowxf.iteye.com/blog/1188496#" pre_index="0" title="java并发测试用例模板" style="display: none;">public class Test {
     public static void main(String[] args) {
          int count = 1000;
          ExecutorService executorService = Executors.newFixedThreadPool(count);
          for (int i = 0; i &lt; count; i++)
               executorService.execute(new Test().new Task());

          executorService.shutdown();
          while (!executorService.isTerminated()) {
               try {
                    Thread.sleep(10);
               } catch (InterruptedException e) {
                    e.printStackTrace();
               }
          }
     }

     public class Task implements Runnable {

          @Override
          public void run() {
               try {
                    // 测试内容
               } catch (Exception e) {
                    e.printStackTrace();
               }
          }
     }
}</pre>如果要实现真正的并发同时执行，可通过CyclicBarrier来控制。
<br><div class="dp-highlighter" id=""><div class="bar"><div class="tools">Java代码 <embed wmode="transparent" src="/javascripts/syntaxhighlighter/clipboard_new.swf" width="14" height="15" flashvars="clipboard=public%20class%20Test%20%7B%0A%20%20%20%20%20public%20static%20void%20main(String%5B%5D%20args)%20%7B%0A%20%20%20%20%20%20%20%20%20%20int%20count%20%3D%201000%3B%0A%20%20%20%20%20%20%20%20%20%20CyclicBarrier%20cyclicBarrier%20%3D%20new%20CyclicBarrier(count)%3B%0A%20%20%20%20%20%20%20%20%20%20ExecutorService%20executorService%20%3D%20Executors.newFixedThreadPool(count)%3B%0A%20%20%20%20%20%20%20%20%20%20for%20(int%20i%20%3D%200%3B%20i%20%3C%20count%3B%20i%2B%2B)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20executorService.execute(new%20Test().new%20Task(cyclicBarrier))%3B%0A%0A%20%20%20%20%20%20%20%20%20%20executorService.shutdown()%3B%0A%20%20%20%20%20%20%20%20%20%20while%20(!executorService.isTerminated())%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20try%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Thread.sleep(10)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%20catch%20(InterruptedException%20e)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20e.printStackTrace()%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%7D%0A%0A%20%20%20%20%20public%20class%20Task%20implements%20Runnable%20%7B%0A%20%20%20%20%20%20%20%20%20%20private%20CyclicBarrier%20cyclicBarrier%3B%0A%0A%20%20%20%20%20%20%20%20%20%20public%20Task(CyclicBarrier%20cyclicBarrier)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20this.cyclicBarrier%20%3D%20cyclicBarrier%3B%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20%20%20%20%20%40Override%0A%20%20%20%20%20%20%20%20%20%20public%20void%20run()%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20try%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2F%2F%20%E7%AD%89%E5%BE%85%E6%89%80%E6%9C%89%E4%BB%BB%E5%8A%A1%E5%87%86%E5%A4%87%E5%B0%B1%E7%BB%AA%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20cyclicBarrier.await()%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2F%2F%20%E6%B5%8B%E8%AF%95%E5%86%85%E5%AE%B9%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%20catch%20(Exception%20e)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20e.printStackTrace()%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%7D%0A%7D" quality="high" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">&nbsp;<a href="javascript:void()" title="收藏这段代码" onclick="code_favorites_do_favorite(this);return false;"><img class="star" src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/icon_star.png" alt="收藏代码"><img class="spinner" src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/spinner.gif" style="display:none"></a></div></div><ol start="1" class="dp-j"><li><span><span class="keyword">public</span><span>&nbsp;</span><span class="keyword">class</span><span>&nbsp;Test&nbsp;{&nbsp;&nbsp;</span></span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">public</span><span>&nbsp;</span><span class="keyword">static</span><span>&nbsp;</span><span class="keyword">void</span><span>&nbsp;main(String[]&nbsp;args)&nbsp;{&nbsp;&nbsp;</span></span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">int</span><span>&nbsp;count&nbsp;=&nbsp;</span><span class="number">1000</span><span>;&nbsp;&nbsp;</span></span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CyclicBarrier&nbsp;cyclicBarrier&nbsp;=&nbsp;<span class="keyword">new</span><span>&nbsp;CyclicBarrier(count);&nbsp;&nbsp;</span></span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ExecutorService&nbsp;executorService&nbsp;=&nbsp;Executors.newFixedThreadPool(count);&nbsp;&nbsp;</span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">for</span><span>&nbsp;(</span><span class="keyword">int</span><span>&nbsp;i&nbsp;=&nbsp;</span><span class="number">0</span><span>;&nbsp;i&nbsp;&lt;&nbsp;count;&nbsp;i++)&nbsp;&nbsp;</span></span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;executorService.execute(<span class="keyword">new</span><span>&nbsp;Test().</span><span class="keyword">new</span><span>&nbsp;Task(cyclicBarrier));&nbsp;&nbsp;</span></span></li><li><span>&nbsp;&nbsp;</span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;executorService.shutdown();&nbsp;&nbsp;</span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">while</span><span>&nbsp;(!executorService.isTerminated())&nbsp;{&nbsp;&nbsp;</span></span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">try</span><span>&nbsp;{&nbsp;&nbsp;</span></span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Thread.sleep(<span class="number">10</span><span>);&nbsp;&nbsp;</span></span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<span class="keyword">catch</span><span>&nbsp;(InterruptedException&nbsp;e)&nbsp;{&nbsp;&nbsp;</span></span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e.printStackTrace();&nbsp;&nbsp;</span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li><span>&nbsp;&nbsp;</span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">public</span><span>&nbsp;</span><span class="keyword">class</span><span>&nbsp;Task&nbsp;</span><span class="keyword">implements</span><span>&nbsp;Runnable&nbsp;{&nbsp;&nbsp;</span></span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">private</span><span>&nbsp;CyclicBarrier&nbsp;cyclicBarrier;&nbsp;&nbsp;</span></span></li><li><span>&nbsp;&nbsp;</span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">public</span><span>&nbsp;Task(CyclicBarrier&nbsp;cyclicBarrier)&nbsp;{&nbsp;&nbsp;</span></span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">this</span><span>.cyclicBarrier&nbsp;=&nbsp;cyclicBarrier;&nbsp;&nbsp;</span></span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li><span>&nbsp;&nbsp;</span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="annotation">@Override</span><span>&nbsp;&nbsp;</span></span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">public</span><span>&nbsp;</span><span class="keyword">void</span><span>&nbsp;run()&nbsp;{&nbsp;&nbsp;</span></span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">try</span><span>&nbsp;{&nbsp;&nbsp;</span></span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">//&nbsp;等待所有任务准备就绪</span><span>&nbsp;&nbsp;</span></span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cyclicBarrier.await();&nbsp;&nbsp;</span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">//&nbsp;测试内容</span><span>&nbsp;&nbsp;</span></span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<span class="keyword">catch</span><span>&nbsp;(Exception&nbsp;e)&nbsp;{&nbsp;&nbsp;</span></span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e.printStackTrace();&nbsp;&nbsp;</span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li><span>}&nbsp;&nbsp;</span></li></ol></div><pre class="java" name="code" codeable_id="" codeable_type="BlogComment" source_url="http://flysnowxf.iteye.com/blog/1188496#" pre_index="1" title="java并发测试用例模板" style="display: none;">public class Test {
     public static void main(String[] args) {
          int count = 1000;
          CyclicBarrier cyclicBarrier = new CyclicBarrier(count);
          ExecutorService executorService = Executors.newFixedThreadPool(count);
          for (int i = 0; i &lt; count; i++)
               executorService.execute(new Test().new Task(cyclicBarrier));

          executorService.shutdown();
          while (!executorService.isTerminated()) {
               try {
                    Thread.sleep(10);
               } catch (InterruptedException e) {
                    e.printStackTrace();
               }
          }
     }

     public class Task implements Runnable {
          private CyclicBarrier cyclicBarrier;

          public Task(CyclicBarrier cyclicBarrier) {
               this.cyclicBarrier = cyclicBarrier;
          }

          @Override
          public void run() {
               try {
                    // 等待所有任务准备就绪
                    cyclicBarrier.await();
                    // 测试内容
               } catch (Exception e) {
                    e.printStackTrace();
               }
          }
     }
}</pre>
  </div>

  

  
  <ins data-revive-zoneid="171" data-revive-id="8c38e720de1c90a6f6ff52f3f89c4d57"></ins>
  

  <div id="bottoms" class="clearfix">
    
    <div id="share_weibo">分享到：
      <a data-type="sina" href="javascript:;" title="分享到新浪微博"><img src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/sina.jpg"></a>
      <a data-type="qq" href="javascript:;" title="分享到腾讯微博"><img src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/tec.jpg"></a>
    </div>
  </div>

  <div class="blog_nav">
    <div class="pre_next">
      <a href="http://flysnowxf.iteye.com/blog/1188727" class="next" title="概率选中的算法实现">概率选中的算法实现</a>
      |
      <a href="http://flysnowxf.iteye.com/blog/1187580" class="pre" title="spring mvc输出xml">spring mvc输出xml</a>
    </div>
  </div>
  <div class="blog_bottom">
    <ul>
      <li>2011-10-10 11:34</li>
      <li>浏览 6899</li>
      <li><a href="http://flysnowxf.iteye.com/blog/1188496#comments">评论(3)</a></li>
       <li>论坛回复 / <a href="http://flysnowxf.iteye.com/topic/1116314">浏览</a> (0 / 1716)</li> 
      
        <li><a href="http://flysnowxf.iteye.com/admin/link?user_favorite%5Btitle%5D=java%E5%B9%B6%E5%8F%91%E6%B5%8B%E8%AF%95%E7%94%A8%E4%BE%8B%E6%A8%A1%E6%9D%BF&amp;user_favorite%5Burl%5D=http%3A%2F%2Fflysnowxf.iteye.com%2Fblog%2F1188496" target="_blank" class="favorite" onclick="$$(&#39;.favorite_form_spinner&#39;)[0].show();new Ajax.Request(&#39;/admin/link/new_xhr?user_favorite%5Btitle%5D=java%E5%B9%B6%E5%8F%91%E6%B5%8B%E8%AF%95%E7%94%A8%E4%BE%8B%E6%A8%A1%E6%9D%BF&amp;user_favorite%5Burl%5D=http%3A%2F%2Fflysnowxf.iteye.com%2Fblog%2F1188496&#39;, {method: &#39;get&#39;, onSuccess: function(response){$(document.getElementsByTagName(&#39;body&#39;)[0]).insert({bottom:response.responseText});$$(&#39;.favorite_form_spinner&#39;)[0].hide();}});return false;">收藏</a><img alt="Spinner" class="favorite_form_spinner" src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/spinner(1).gif" style="vertical-align:bottom;margin-left:7px;display:none;"></li>
      
      <li>分类:<a href="http://www.iteye.com/blogs/category/language">编程语言</a></li>      
      <li class="last"><a href="http://www.iteye.com/wiki/blog/1188496" target="_blank" class="more">相关推荐</a></li>
    </ul>    
  </div>
  
		    
		
<div class="boutique-curr-box blog_comment">
	  <div class="boutique-curr clearfix">
	    <h5 class="h3titles">参考知识库</h5>
	    
	    <dl class="dlnewlist">
	    
          <dd><a target="_blank" href="http://lib.csdn.net/base/javase"><img src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/1453169124297_297.jpg" width="58" height="58" alt=""></a></dd>
          <dt>
              <a target="_blank" href="http://lib.csdn.net/base/javase" classs="title">Java SE知识库</a>
              <span>
                 <em>12859</em>&nbsp;&nbsp;关注 <i>|</i> <em>450</em>&nbsp;&nbsp;收录                  
              </span>
          </dt>
      
	    </dl>
	    
	    <dl class="dlnewlist">
	    
          <dd><a target="_blank" href="http://lib.csdn.net/base/java"><img src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/1453701371636_636.jpg" width="58" height="58" alt=""></a></dd>
          <dt>
              <a target="_blank" href="http://lib.csdn.net/base/java" classs="title">Java 知识库</a>
              <span>
                 <em>13704</em>&nbsp;&nbsp;关注 <i>|</i> <em>1195</em>&nbsp;&nbsp;收录                  
              </span>
          </dt>
      
	    </dl>
	    
	    <dl class="dlnewlist">
	    
          <dd><a target="_blank" href="http://lib.csdn.net/base/javaee"><img src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/1456818035722_722.jpg" width="58" height="58" alt=""></a></dd>
          <dt>
              <a target="_blank" href="http://lib.csdn.net/base/javaee" classs="title">Java EE知识库</a>
              <span>
                 <em>5092</em>&nbsp;&nbsp;关注 <i>|</i> <em>622</em>&nbsp;&nbsp;收录                  
              </span>
          </dt>
      
	    </dl>
	    
	    <dl class="dlnewlist">
	    
          <dd><a target="_blank" href="http://lib.csdn.net/base/javascript"><img src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/1458106113412_412.jpg" width="58" height="58" alt=""></a></dd>
          <dt>
              <a target="_blank" href="http://lib.csdn.net/base/javascript" classs="title">JavaScript知识库</a>
              <span>
                 <em>5405</em>&nbsp;&nbsp;关注 <i>|</i> <em>1308</em>&nbsp;&nbsp;收录                  
              </span>
          </dt>
      
	    </dl>
	    
	  </div>
</div>
 		
      
  <div class="blog_comment">
    <h5>评论</h5>
    <a id="comments" name="comments"></a>
    <div id="bc2349125">
  <div class="comment_title">
    3 楼
    <a href="http://flysnowxf.iteye.com/" target="_blank" title="flysnowxf">flysnowxf</a>
    2014-05-26&nbsp;&nbsp;
    <a href="http://flysnowxf.iteye.com/blog/1188496#" onclick="quote_comment(2349125);return false;">引用</a>
    
  </div>
  <div class="comment_content"><div class="quote_title">shibin_1109 写道</div><div class="quote_div">10-16行为什么要让没有执行完的线程睡眠呢?找了好久不理解为什么?还有那个Thread是正在执行的线程么?</div><br><br>很久没来这里了，不好意思。在main函数这个Thread中，Thread.sleep(10)指的就是这个main进程。executorService是异步执行任务的，如果不通过executorService.isTerminated()来休眠main进程，那么1000个Task任务都没有执行完，main就先执行完了然后关掉了整个程序。你去掉while那段代码试试，你会发现刚运行然后程序就结束了。</div>
</div>

<div id="bc2343949">
  <div class="comment_title">
    2 楼
    <a href="http://shibin-1109.iteye.com/" target="_blank" title="shibin_1109">shibin_1109</a>
    2014-03-31&nbsp;&nbsp;
    <a href="http://flysnowxf.iteye.com/blog/1188496#" onclick="quote_comment(2343949);return false;">引用</a>
    
  </div>
  <div class="comment_content">10-16行为什么要让没有执行完的线程睡眠呢?找了好久不理解为什么?还有那个Thread是正在执行的线程么?</div>
</div>

<div id="bc2319700">
  <div class="comment_title">
    1 楼
    <a href="http://xuhang1128.iteye.com/" target="_blank" title="xuhang1128">xuhang1128</a>
    2013-07-23&nbsp;&nbsp;
    <a href="http://flysnowxf.iteye.com/blog/1188496#" onclick="quote_comment(2319700);return false;">引用</a>
    
  </div>
  <div class="comment_content">good！</div>
</div>


    
    
  </div>

  <div class="blog_comment">
    <h5>发表评论</h5>
            <form action="http://flysnowxf.iteye.com/blog/1188496" id="comment_form" method="post" onsubmit="return false;"><div style="margin:0;padding:0;display:inline"><input name="authenticity_token" type="hidden" value="jBwEOXnoendouP0ySYchqzCPkfQkm4V54086TLW4dVY="></div>          


  <input type="hidden" id="editor_bbcode_flag" value="true">



<div id="editor_main"><div id="editor_wrapper" class="clearfix"><div id="bbcode_emotions"><h5>表情图标</h5><img src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/icon_biggrin.gif"><img src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/icon_smile.gif"><img src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/icon_sad.gif"><img src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/icon_surprised.gif"><img src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/icon_eek.gif"><img src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/icon_confused.gif"><img src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/icon_cool.gif"><img src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/icon_lol.gif"><img src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/icon_mad.gif"><img src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/icon_razz.gif"><img src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/icon_redface.gif"><img src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/icon_cry.gif"><img src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/icon_evil.gif"><img src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/icon_twisted.gif"><img src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/icon_rolleyes.gif"><img src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/icon_wink.gif"><img src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/icon_exclaim.gif"><img src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/icon_question.gif"><img src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/icon_idea.gif"><img src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/icon_arrow.gif"></div><div id="bbcode_controllers"><div id="bbcode_toolbar"><input type="button" value="B" id="button_bold"><input type="button" value="I" id="button_italic"><input type="button" value="U" id="button_underline"><input type="button" value="Quote"><input type="button" value="Code"><input type="button" value="List"><input type="button" value="Img"><input type="button" value="URL"><input type="button" value="Flash"><input type="button" value="Table"><br>字体颜色: <select id="select_color"><option value="black" style="color: black;">标准</option><option value="darkred" style="color: darkred;">深红</option><option value="red" style="color: red;">红色</option><option value="orange" style="color: orange;">橙色</option><option value="brown" style="color: brown;">棕色</option><option value="yellow" style="color: yellow;">黄色</option><option value="green" style="color: green;">绿色</option><option value="olive" style="color: olive;">橄榄</option><option value="cyan" style="color: cyan;">青色</option><option value="blue" style="color: blue;">蓝色</option><option value="darkblue" style="color: darkblue;">深蓝</option><option value="indigo" style="color: indigo;">靛蓝</option><option value="violet" style="color: violet;">紫色</option><option value="gray" style="color: gray;">灰色</option><option value="white" style="color: white;">白色</option><option value="black" style="color: black;">黑色</option></select>&nbsp;字体大小: <select id="select_font"><option value="0">标准</option><option value="xx-small">1 (xx-small)</option><option value="x-small">2 (x-small)</option><option value="small">3 (small)</option><option value="medium">4 (medium)</option><option value="large">5 (large)</option><option value="x-large">6 (x-large)</option><option value="xx-large">7 (xx-large)</option></select>&nbsp;对齐: <select id="select_align"><option value="0">标准</option><option value="left">居左</option><option value="center">居中</option><option value="right">居右</option></select></div><div id="bbcode_tooltip">提示：选择您需要装饰的文字, 按上列按钮即可添加上相应的标签</div><textarea class="validate-richeditor bad-words min-length-5" cols="40" id="editor_body" name="comment[body]" rows="20" style="width: 500px; height: 350px;"></textarea></div></div></div>


<script type="text/javascript">
  var editor = new Control.TextArea.Editor("editor_body", "bbcode", false);
</script>

          <p style="text-align:right;margin-right:30px;">(快捷键 Alt+S / Ctrl+Enter) <input class="submit" id="quick_reply_button" name="commit" type="submit" value="提交"></p>
       </form>
        <script type="text/javascript">
          new HotKey("s",function() {$('quick_reply_button').click();},{altKey: true, ctrlKey: false});
          new HotKey(new Number(13),function() {$('quick_reply_button').click();},{altKey: false, ctrlKey: true});

          new Validation("comment_form", {immediate: false, onFormValidate: function(result, form){
            if(result) {
              new Ajax.Request('/blog/create_comment/1188496', {
                onFailure:function(response){
                  $('comments').insert({after:response.responseText})
                  form.spinner.hide();
                  Element.scrollTo($('comments'));
                },
                onSuccess:function(response){
                  Element.scrollTo($('comments'));
                  var new_comment = new Element('div', {}).update(response.responseText).firstChild;
                  var comment_id = new_comment.readAttribute('id');

                  $('comments').insert({after:response.responseText});
                  $('editor_body').value = "";

                  var css_rules = '#' + comment_id + ' pre';
                  highlightNewAddContent(css_rules);
                  processComment();
                  code_favorites_init(css_rules);
                  
                  form.spinner.hide();
                }, parameters:Form.serialize(form)
              });
            }
        }});
        </script>
        </div>
</div>


<script type="text/javascript">
  dp.SyntaxHighlighter.HighlightAll('code', true, true);

  $$('#main .blog_content pre[name=code]').each(function(pre, index){ // blog content
    var post_id = 1188496;
    var location = window.location;
    source_url = location.protocol + "//" + location.host + location.pathname + location.search;
    pre.writeAttribute('codeable_id', post_id);
    pre.writeAttribute('codeable_type', "Blog");
    pre.writeAttribute('source_url', source_url);
    pre.writeAttribute('pre_index', index);
    pre.writeAttribute('title', 'java并发测试用例模板');
  });

  fix_image_size($$('div.blog_content img'), 700);

  function processComment() {
    $$('#main .blog_comment > div').each(function(comment){// comment
      var post_id = comment.id.substr(2);
      $$("#"+comment.id+" pre[name=code]").each(function(pre, index){
        var location = window.location;
        source_url = location.protocol + "//" + location.host + location.pathname + location.search;
        source_url += "#" + comment.id;
        pre.writeAttribute('codeable_id', post_id);
        pre.writeAttribute('codeable_type', "BlogComment");
        pre.writeAttribute('source_url', source_url);
        pre.writeAttribute('pre_index', index);
        pre.writeAttribute('title', 'java并发测试用例模板');
      });
    });
  }

  function quote_comment(id) {
    new Ajax.Request('/editor/quote', {
      parameters: {'id':id, 'type':'BlogComment'},
      onSuccess:function(response){editor.bbcode_editor.textarea.insertAfterSelection(response.responseText);
        Element.scrollTo(editor.bbcode_editor.textarea.element);}
    });
  }

  code_favorites_init();
  processComment();
  new WeiboShare({share_buttons: $('share_weibo'), img_scope: $('blog_content')});
</script>




        </div>

        <div id="local">
          <div class="local_top"></div>
          <div id="blog_owner">
  <div id="blog_owner_logo"><a href="http://flysnowxf.iteye.com/"><img alt="flysnowxf的博客" class="logo" src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/4668df67-2460-3d51-96fc-78de8b13dcbd.gif" title="flysnowxf的博客: flysnowxf技术博客" width=""></a></div>
  <div id="blog_owner_name">flysnowxf</div>
</div>

          <div id="blog_actions">
            <ul>
              <li>浏览: 253852 次</li>
              <li>性别: <img alt="Icon_minigender_1" src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/icon_minigender_1.gif" title="男"></li>
              <li>来自: 北京</li>
              <li><img src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/offline.gif"></li>
              
                <li>
                  <a href="http://my.iteye.com/messages/new?message%5Breceiver_name%5D=flysnowxf" class="message" title="发送站内短信">发短消息</a>
                  
                    <a href="http://my.iteye.com/feed?subscription%5Bsubscribed_user_name%5D=flysnowxf" class="subscription" onclick="var f = document.createElement(&#39;form&#39;); f.style.display = &#39;none&#39;; this.parentNode.appendChild(f); f.method = &#39;POST&#39;; f.action = this.href;var s = document.createElement(&#39;input&#39;); s.setAttribute(&#39;type&#39;, &#39;hidden&#39;); s.setAttribute(&#39;name&#39;, &#39;authenticity_token&#39;); s.setAttribute(&#39;value&#39;, &#39;jBwEOXnoendouP0ySYchqzCPkfQkm4V54086TLW4dVY=&#39;); f.appendChild(s);f.submit();return false;">关注</a>
                  
                </li>
              
            </ul>
          </div>
          <div id="user_visits" class="clearfix">
            <h5>最近访客 <span style="font-weight:normal;font-size:12px;padding-left:30px;"><a href="http://flysnowxf.iteye.com/blog/user_visits">更多访客&gt;&gt;</a></span></h5>
            
              <div class="user_visit">
                <div class="logo"><a href="http://haiyang4988.iteye.com/" target="_blank"><img alt="haiyang4988的博客" class="logo" src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/user-logo-thumb.gif" title="haiyang4988的博客: " width="48px"></a></div>
                <div class="left"><a href="http://haiyang4988.iteye.com/" target="_blank" title="haiyang4988">haiyang4988</a></div>
              </div>
            
              <div class="user_visit">
                <div class="logo"><a href="http://rusherhk.iteye.com/" target="_blank"><img alt="Rusherhk的博客" class="logo" src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/user-logo-thumb.gif" title="Rusherhk的博客: " width="48px"></a></div>
                <div class="left"><a href="http://rusherhk.iteye.com/" target="_blank" title="Rusherhk">Rusherhk</a></div>
              </div>
            
              <div class="user_visit">
                <div class="logo"><a href="http://udblfd.iteye.com/" target="_blank"><img alt="udblfd的博客" class="logo" src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/user-logo-thumb.gif" title="udblfd的博客: " width="48px"></a></div>
                <div class="left"><a href="http://udblfd.iteye.com/" target="_blank" title="udblfd">udblfd</a></div>
              </div>
            
              <div class="user_visit">
                <div class="logo"><a href="http://patrickhan.iteye.com/" target="_blank"><img alt="patrickhan的博客" class="logo" src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/user-logo-thumb.gif" title="patrickhan的博客: " width="48px"></a></div>
                <div class="left"><a href="http://patrickhan.iteye.com/" target="_blank" title="patrickhan">patrickhan</a></div>
              </div>
            
          </div>

          

                      <div id="blog_menu">
              <h5>文章分类</h5>
              <ul>
                <li><a href="http://flysnowxf.iteye.com/">全部博客 (91)</a></li>
                
                  <li><a href="http://flysnowxf.iteye.com/category/73014">Translation (3)</a></li>
                
                  <li><a href="http://flysnowxf.iteye.com/category/95072">Java (18)</a></li>
                
                  <li><a href="http://flysnowxf.iteye.com/category/95777">Cache (5)</a></li>
                
                  <li><a href="http://flysnowxf.iteye.com/category/95780">Common (5)</a></li>
                
                  <li><a href="http://flysnowxf.iteye.com/category/95781">Database (13)</a></li>
                
                  <li><a href="http://flysnowxf.iteye.com/category/103777">Linux (10)</a></li>
                
                  <li><a href="http://flysnowxf.iteye.com/category/103778">Web (7)</a></li>
                
                  <li><a href="http://flysnowxf.iteye.com/category/104416">LoadBalance (2)</a></li>
                
                  <li><a href="http://flysnowxf.iteye.com/category/108592">Tool (8)</a></li>
                
                  <li><a href="http://flysnowxf.iteye.com/category/111823">Algorithm (3)</a></li>
                
                  <li><a href="http://flysnowxf.iteye.com/category/112413">Protocol (2)</a></li>
                
                  <li><a href="http://flysnowxf.iteye.com/category/125654">Search (7)</a></li>
                
                  <li><a href="http://flysnowxf.iteye.com/category/163449">Python (4)</a></li>
                
                  <li><a href="http://flysnowxf.iteye.com/category/224378">Interview (1)</a></li>
                
                  <li><a href="http://flysnowxf.iteye.com/category/229600">Git (1)</a></li>
                
              </ul>
            </div>
            <div id="month_blogs">
              <h5>社区版块</h5>
              <ul>
                <li><a href="http://flysnowxf.iteye.com/blog/news">我的资讯</a> (0)</li>
                <li>
                  <a href="http://flysnowxf.iteye.com/blog/post">我的论坛</a> (130)
                </li>
                <li><a href="http://flysnowxf.iteye.com/blog/answered_problems">我的问答</a> (2)</li>
              </ul>
            </div>
            <div id="month_blogs">
              <h5>存档分类</h5>
              <ul>
                
                  <li><a href="http://flysnowxf.iteye.com/blog/monthblog/2012-09">2012-09</a> (1)</li>
                
                  <li><a href="http://flysnowxf.iteye.com/blog/monthblog/2012-06">2012-06</a> (3)</li>
                
                  <li><a href="http://flysnowxf.iteye.com/blog/monthblog/2012-05">2012-05</a> (4)</li>
                
                <li><a href="http://flysnowxf.iteye.com/blog/monthblog_more">更多存档...</a></li>
              </ul>
            </div>
            
            

            <div id="guest_books">
              <h5>最新评论</h5>
              <ul>
                
                <li>
                  <a href="http://hongyuan19.iteye.com/" target="_blank" title="hongyuan19">hongyuan19</a>： 
                  ron.luo 写道我也有此疑问，求解。使用Intercept ...<br>
                  <a href="http://flysnowxf.iteye.com/blog/1187567#bc2384967">spring mvc获取header</a>
                </li>
                
                <li>
                  <a href="http://2621482946-qq-com.iteye.com/" target="_blank" title="ron.luo">ron.luo</a>： 
                  我也有此疑问，求解。<br>
                  <a href="http://flysnowxf.iteye.com/blog/1187567#bc2380978">spring mvc获取header</a>
                </li>
                
                <li>
                  <a href="http://wzhj0528.iteye.com/" target="_blank" title="wzhj0528">wzhj0528</a>： 
                  vi /etc/selinux/config&nbsp; SELINUX ...<br>
                  <a href="http://flysnowxf.iteye.com/blog/1567570#bc2373544">ssh使用公钥授权不通过的问题解决</a>
                </li>
                
                <li>
                  <a href="http://xuhuan1108.iteye.com/" target="_blank" title="xuhuan1108">xuhuan1108</a>： 
                  请问请问一下：使用Spring&nbsp; MVC 怎么预先统一处理所有 ...<br>
                  <a href="http://flysnowxf.iteye.com/blog/1187567#bc2363785">spring mvc获取header</a>
                </li>
                
                <li>
                  <a href="http://mozheshashou.iteye.com/" target="_blank" title="mozheshashou">mozheshashou</a>： 
                  你好 我按你的设置了以后怎么条件都没有起作用了呢<br>
                  <a href="http://flysnowxf.iteye.com/blog/963970#bc2363400">solr查询如何支持多个fq</a>
                </li>
                
              </ul>
            </div>

            <div class="local_bottom"></div>
          
        </div>
        <div style="margin-top: 10px;float: left;clear: left;">
					<ins data-revive-zoneid="185" data-revive-id="8c38e720de1c90a6f6ff52f3f89c4d57"></ins>
				</div>
      </div>    

      <div id="footer" class="clearfix">
        <div id="copyright">
          <hr>
          声明：ITeye文章版权属于作者，受法律保护。没有作者书面许可不得转载。若作者同意转载，必须以超链接形式标明文章原始出处和作者。<br>
          © 2003-2016 ITeye.com.   All rights reserved.  [ 京ICP证110151号  京公网安备110105010620 ]
        </div>
        <ins data-revive-zoneid="186" data-revive-id="8c38e720de1c90a6f6ff52f3f89c4d57"></ins>
      </div>
    </div>
    <script type="text/javascript">
  document.write("<img src='http://stat.iteye.com/?url="+ encodeURIComponent(document.location.href) + "&referrer=" + encodeURIComponent(document.referrer) + "&user_id=307854' width='0' height='0' />");
</script><img src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/saved_resource" width="0" height="0">

<script src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/tracking.js" type="text/javascript"></script>

    
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-27884360-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
      
    
    <script language="javascript" type="text/javascript" src="http://ads.csdn.net/js/async_new.js"></script>
<script src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/jquery-1.11.1.min.js" type="text/javascript"></script>
<script type="text/javascript">var $csdn_iteye_jq = jQuery.noConflict();// 解决jq与prototype.js命名空间冲突的问题</script>
<script src="http://ads.csdn.net/js/tracking.js" type="text/javascript"></script>
    
	    
	    <script src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/web-storage-cache.min.js" type="text/javascript"></script>
	    <script src="./java并发测试用例模板 - flysnowxf技术博客 - ITeye技术网站_files/replace.min.js" type="text/javascript"></script>
    
    
  

</body></html>